import permision from "@/js_sdk/wa-permission/permission.js"
export function filterName (name) {
	if(!name){
		return ''
	}else{
		return name.slice(0,1) + '**'
	}
}
// 金额
export function filterPrice (price) {
	if(!price){
		return '0.00'
	}else{
		return price.toFixed(2)
	}
}
// 手机号
export function filterPhone (phone) {
	if(!phone){
		return '-'
	}else{
		let result = phone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
		return result
	}
}
// 检测相机权限
export const checkAlbumPermision = async () => {
	var platform = uni.getSystemInfoSync().platform;
	var isOpen = ''
	if(platform === 'android'){
		// 安卓
		var result = await permision.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE')
		console.log('android result', result)
		if (result == 1) {
			isOpen = true
		}else{
			// 未开启权限
			isOpen = false
		}
	}else{
		// ios
		var result = permision.judgeIosPermission("photoLibrary")
		console.log('ios result', result)
		// if(result){
		// 	isOpen = true
		// }else{
		// 	// 未开启权限
		// 	isOpen = false
		// }
		// ios uni.chooseImage 自己判断权限
		isOpen = true
	}
	return isOpen
}
